package org.openclinic.service.impl;

import java.util.Date;
import java.util.List;

import org.openclinic.domain.Attendant;
import org.openclinic.domain.Reminder;
import org.openclinic.repository.ReminderRepository;
import org.openclinic.service.ReminderService;
import org.openclinic.web.context.AttributeRetriever;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReminderServiceImpl implements ReminderService {
	
	@Autowired
	private ReminderRepository reminderRepository;
	
	@Override
	public void delete(long id) {
		reminderRepository.delete(id);
	}
	
	@Override
	public List<Reminder> findByCustomer(long id) {
		return reminderRepository.findByCustomerId(id);
	}
	
	@Override
	public List<Reminder> findTodayImportantReminders() {
		return reminderRepository.findTodayImportantReminders();
	}
	
	@Override
	public Reminder save(Reminder reminder) {
		reminder.setAttendant((Attendant)AttributeRetriever.getUserFromSession());
		reminder.setCreationDate(new Date());
		return reminderRepository.save(reminder);
	}
}
